package com.deepgames.mud.action;

import java.util.HashMap;
import java.util.Map;

import com.deepgames.mud.action.book.core.*;
import com.deepgames.mud.action.data.Action;
import com.deepgames.mud.core.InternalCode;

// TODO Insert loadActionLibrary with no arguments to pre-load core actions.
/**
 * Collection which loads and accesses externally loaded ActionBook and Action
 * 	classes.
 * 
 * @author Zack Hoffmann
 * @version 0.1
 *
 */
public class ActionLibrary {

	private Map<String,Action> actions;
	
	/**
	 * Constructor initializing internal values.
	 */
	public ActionLibrary() {
		actions = new HashMap<String,Action>();
	}
	
	public int loadActionLibrary() {
		int status = InternalCode.SUCCESS;
		
		actions.put("LOGIN", new Login());
		actions.put("NEW_PLAYER", new NewPlayer());
		
		return status;
	}
	
	/**
	 * Retrieves an Action instance associated with the command word.  The
	 * 	command word can either be the name of the action or an alias as
	 * 	specified in the action's action book.
	 * 
	 * @param command		A name or alias to which an Action instance may be
	 * 							mapped.
	 * @return				An instance of the Action referenced by the
	 * 							command.  NOTE: This Action may be persistent,
	 * 							but it is not guaranteed to be.  Instance
	 * 							fields will be eliminated if the action's
	 * 							action book is reloaded.
	 */
	public Action lookupAction(String command) {
		Action act = null;
		
		act = actions.get(command.toUpperCase());
		
		return act;
	}

}
